$(function () {
    layui.use(['table','layer'],function () {
        var table = layui.table;
        var layer = layui.layer;
        table.render({
            elem:'#listSplit',
            url:'/pages/back/orderDe/listSplit1',
            page:true,
            limit:10,
            cols:[[
                {field: 'orid', title: '订单编号',sort: true, fixed: 'left'},
                {field: 'cuid', title: '客户编号',sort: true, fixed: 'left'},
                {field: 'title', title: '货物名称',sort: true, fixed: 'left'},
                {field: 'number', title: '货物数量',sort: true, fixed: 'left'},
                {field: 'start', title:'出发地',sort: true, fixed: 'left'},
                {field: 'end', title:'目的地',sort: true, fixed: 'left'},
                {
                    field: 'orderdate',
                    title: '创建日期',
                    templet: "<div>{{layui.util.toDateString(d.orderdate,'yyyy-MM-dd HH:mm:ss')}}</div>"
                },
                {
                    field: 'delivery',
                    title: '运输时间',
                    templet: "<div>{{layui.util.toDateString(d.delivery,'yyyy-MM-dd HH:mm:ss')}}</div>"
                },
                {field:'status',title:'状态',templet:'#status'},
                {field:'right',title:'操作',templet:"#barOption"}
            ]]
        })
        table.on('tool(listSplit)',function (obj) {
            var data = obj.data;
            if(obj.event == "editStatus"){
                var orid = data.orid;
                        $.ajax({
                            url:'/pages/back/orderDe/editOrderDeStatus',
                            type:'post',
                            data:{'orid':orid},
                            success:function (data) {
                                if(data=="success"){
                                    layer.msg("订单完结成功",{time:1000,icon:1,end:function () {
                                            window.location.href="/pages/back/orderDe/listSplitPre1"
                                        }})
                                }else if (data=="isEmpty"){
                                    layer.msg("数据有误",{time:1000,icon:2})
                                }else{
                                    layer.msg("订单完结失败",{time:1000,icon:2})
                                }
                            }
                        })
            }

        })

    })
})